/**
 * Created by GadflyBSD on 16/3/12.
 */
var templatePath = 'Public/template/Customer/';
var meta = new Object();
var content = document.getElementsByTagName('meta');
for(var i=0;i<content.length;i++){
	if(content[i].getAttribute('name') == 'login')
		meta.login = content[i].getAttribute('content');
	if(content[i].getAttribute('name') == 'logout')
		meta.logout = content[i].getAttribute('content');
	if(content[i].getAttribute('name') == 'register')
		meta.register = content[i].getAttribute('content');
	if(content[i].getAttribute('name') == 'Authcode')
		meta.appurl = content[i].getAttribute('content');
	if(content[i].getAttribute('name') == 'appurl')
		meta.verifyImg = content[i].getAttribute('content');
	if(content[i].getAttribute('name') == 'verifySms')
		meta.verifySms = content[i].getAttribute('content');
	if(content[i].getAttribute('name') == 'upload')
		meta.upload = content[i].getAttribute('content');
	if(content[i].getAttribute('name') == 'load')
		meta.load = content[i].getAttribute('content');
	if(content[i].getAttribute('name') == 'ajax')
		meta.ajax = content[i].getAttribute('content');
	if(content[i].getAttribute('name') == 'angular')
		meta.angular = content[i].getAttribute('content');
}
var myApp = angular.module('myApp', ['ngRoute', 'myApp.index', 'myApp.cookie', 'myApp.show']);
myApp.config(['$routeProvider', function($routeProvider) {
	$routeProvider.when('/index', {
		templateUrl: templatePath + 'index.html',
		controller: 'indexCtrl'
	}).
	when('/cookie', {
		templateUrl: templatePath + 'cookie.html',
		controller: 'cookieCtrl'
	}).
	when('/show', {
		templateUrl: templatePath + 'show.html',
		controller: 'showCtrl'
	}).otherwise({redirectTo: '/index'});
}]).
factory('cookieService', ['$http', function($http){
	return {
		getCookie: function(){
			return $http.post(meta.angular, {
				ac: 'angular',
				op: 'getCookie'
			});
		}
	}
}]);

angular.module('myApp.index', ['ngRoute', 'ngCookies']).
controller('indexCtrl', ['$scope', '$cookies', function($scope, $cookies){
	$cookies.put('s_param', 'Gadfly');
	$cookies.put('s_num', 1);
	console.log($cookies.getAll());
}]);

angular.module('myApp.cookie', ['ngRoute', 'ngCookies']).
controller('cookieCtrl', ['$scope', '$cookies', 'cookieService', '$location', function($scope, $cookies, cookieService, $location) {
	/*cookieService.getCookie().success(function(resp){

	});*/
	$location.path('/show');
	$location.replace();
}]);

angular.module('myApp.show', ['ngRoute']).
controller('showCtrl', ['$scope', function($scope) {
	"use strict";

}]);